Tanstack Routerでcode-based routing
from TanStack Router
コードベースルーティング
このあたりを使う
createRootRoute
createRoute
https://tanstack.com/router/latest/docs/framework/react/routing/code-based-routing
https://tanstack.com/router/latest/docs/framework/react/quick-start#using-code-based-route-configuration
code:ts
import {
createRootRoute,
createRoute,
createRouter,
RouterProvider,
Link,
Outlet,
} from '@tanstack/react-router'
const rootRoute = createRootRoute({ component: AppLayout })
const indexRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/',
component: Home,
})
const aboutRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/about',
component: About,
})
const routeTree = rootRoute.addChildren(indexRoute, aboutRoute)
const router = createRouter({ routeTree })